<?php

namespace Lib\Util;

class Session {

    public static function start() {
        session_start();
    }

    public static function read($key) {
        return @$_SESSION[$key];
    }

    public static function write($key, $value) {
        if (! isset($_SESSION[$key])) {
            $_SESSION[$key] = '';
        }
        $_SESSION[$key] = $value;
    }

    public static function delete($key) {
        unset($_SESSION[$key]);
    }

    public static function all() {
        return $_SESSION;
    }

    public static function flash($message, $type='info') {
        self::write('Flash.message', $message);
        self::write('Flash.type', $type);
    }

}